package com.pay.alipay.config;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Data
@AllArgsConstructor
@ToString
@NoArgsConstructor
@Component
@ConfigurationProperties(prefix = "alipay")
public class AliPayConfig {
   //应用id
    @Value("${alipay.app_id}")
    public String app_id;
    //应用私钥
    @Value("${alipay.merchant_private_key}")
    public String merchant_private_key;
    //支付宝公钥
    @Value("${alipay.alipay_public_key}")
    public String alipay_public_key;
    //异步通知
    @Value("${alipay.notify_url}")
    public String notify_url;
    //同步通知
    @Value("${alipay.return_url}")
    public String return_url;
    //签名类型
    @Value("${alipay.sign_type}")
    public String sign_type;
    //字符类型
    @Value("${alipay.charset}")
    public String charset;
    //支付宝网关
    @Value("${alipay.gatewatUrl}")
    public String gatewatUrl;

    @Bean
    public AliPayConfig getAliPayConfig(){
     AliPayConfig aliPayConfig=new AliPayConfig();
     aliPayConfig.setApp_id(app_id);
     aliPayConfig.setMerchant_private_key(merchant_private_key);
     aliPayConfig.setAlipay_public_key(alipay_public_key);
     aliPayConfig.setNotify_url(notify_url);
     aliPayConfig.setReturn_url(return_url);
     aliPayConfig.setSign_type(sign_type);
     aliPayConfig.setCharset(charset);
     System.out.println(charset);
     aliPayConfig.setGatewatUrl(gatewatUrl);
     return aliPayConfig;
    }
}
